package org.git.movie.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.git.movie.entity.RecommendSites;
import org.git.movie.mapper.ext.RecommendSitesExtMapper;
import org.git.movie.service.RecommendSitesService;
import org.git.movie.vo.PageDto;
import org.git.movie.vo.RecommendSitesDto;
import org.git.movie.vo.VodRecommendDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sqyc
 */
@Service
@Slf4j
public class RecommendSitesServiceImpl implements RecommendSitesService {


    @Autowired
    private RecommendSitesExtMapper recommendSitesExtMapper ;

    @Override
    public PageDto<RecommendSitesDto> findPage(RecommendSites recommendSites, int pageNo, int pageSize) {
        try{
            PageHelper.startPage(pageNo, pageSize, true);
            List<RecommendSitesDto> list = recommendSitesExtMapper.findPage(recommendSites);
            //用PageInfo对结果进行包装
            PageInfo page = new PageInfo(list);
            //自定义转换方法
            return   PageDto.transPageInfo(page);

        }finally {
            PageHelper.clearPage();
        }
    }
}
